package com.ndphu.comic.gui.list.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.DecelerateInterpolator;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.ndphu.comic.R;
import com.ndphu.comic.gui.list.model.SearchBookItem;

public class SearchBookItemAdapter extends ArrayAdapter<SearchBookItem> {

	private LayoutInflater mInflater;

	public SearchBookItemAdapter(Context context, int textViewResourceId) {
		super(context, textViewResourceId);
		mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null || convertView.getTag() == null || !(convertView.getTag() instanceof ViewHolder)) {
			convertView = mInflater.inflate(R.layout.listitem_search_book_item, parent, false);
			ViewHolder holder = new ViewHolder();
			holder.bookName = (TextView) convertView.findViewById(R.id.listitem_search_book_item_book_name);
			holder.desc = (TextView) convertView.findViewById(R.id.listitem_search_book_item_desc);
			convertView.setTag(holder);
		}
		ViewHolder holder = (ViewHolder) convertView.getTag();
		SearchBookItem item = getItem(position);
		fillDataToItem(holder, item);
		return convertView;
	}

	private void fillDataToItem(ViewHolder holder, SearchBookItem item) {
		holder.bookName.setText(item.bookName);
		holder.desc.setText(item.bookLink);
	}

	public static class ViewHolder {
		TextView bookName;
		TextView desc;
	}

}
